//
//  EFADeviceTCell.m
//  efairy
//
//  Created by XiangDongMBP on 2017/7/12.
//  Copyright © 2017年 East. All rights reserved.
//

#import "EFADeviceTCell.h"
#import "EFAModel.h"
#import "UIColor+XDHex.h"
#import "GlobalHeader.h"

@implementation EFADeviceTCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    [self.deviceNoteBtn addTarget:self action:@selector(deviceNoteBtnTapped:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)deviceNoteBtnTapped:(UIButton *)btn {
    if ([self.delegate respondsToSelector:@selector(deviceTCell:deviceNoteBtnTapped:)]) {
        [self.delegate deviceTCell:self deviceNoteBtnTapped:btn];
    }
}

- (void)configViewWithDeviceListItem:(EFADeviceListItem *)item {
    self.portraitImgView.alpha = item.efairydevice_is_online ? 1.0 : 0.6;
    self.deviceNameLabel.text = item.efairydevice_name;
    self.deviceOnlineLabel.text = item.efairydevice_is_online ? @"【在线】" : @"【离线】";
    NSUInteger color = item.efairydevice_is_online ? EFAGlobalColorDarkGreen : EFAGlobalColorFontLightBlack;
    self.deviceOnlineLabel.textColor = [UIColor xd_colorWithHex:color];
    self.deviceStateLabel.text = item.three_state_str;
    self.deviceStateLabel.textColor = [UIColor xd_colorWithHexString:item.map_state_color];
}

@end
